package com.example.weather_plus.ui.weathergram.Items;

import android.annotation.SuppressLint;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Card {

    Date createTime;    // 创建时间

    long cardId;        // 卡片类型 -1代表分节符 0代表普通卡片
    String title;       // 标题
    String date;        // 日期
    String week;        // 缩写星期
    String time;        // 时间
    String context;     // 内容
    String month;       // 月份缩写
    String month_long;  // 月份全称
    String week_long;   // 星期全称
    String entries_id;

    public String getEntries_id() {
        return entries_id;
    }

    public void setEntries_id(String entries_id) {
        this.entries_id = entries_id;
    }

    public Card(long cardId, String title, String context, String date, String id) {

        this.cardId = cardId;
        this.title = title;
        this.context = context;
        this.entries_id = id;

        // 根据Bmob数据库的系统自带创建时间属性确定创建笔记的时间
        @SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 设置日期格式

        try {
            this.createTime = formatter.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }


        // 使用SimpleDateFormat来格式化日期
        SimpleDateFormat monthFormat = new SimpleDateFormat("MM", Locale.getDefault());
        this.month = monthFormat.format(this.createTime);

        // 日期全称
        SimpleDateFormat monthFormatLong = new SimpleDateFormat("MMMM", Locale.getDefault());
        this.month_long = monthFormatLong.format(this.createTime);

        // 使用SimpleDateFormat来格式化日期
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd", Locale.getDefault());
        this.date = dateFormat.format(this.createTime);

        // 使用SimpleDateFormat来格式化星期（注意：星期几是依据Locale来决定的，可能需要调整）
        SimpleDateFormat weekdayFormat = new SimpleDateFormat("EEE", Locale.ENGLISH);
        this.week = weekdayFormat.format(this.createTime);

        // 星期全称
        SimpleDateFormat weekdayFormatLong = new SimpleDateFormat("EEEE", Locale.ENGLISH);
        this.week_long = weekdayFormatLong.format(this.createTime);

        // 使用SimpleDateFormat来格式化时间
        SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm", Locale.getDefault());
        this.time = timeFormat.format(this.createTime);

    }

    public String getWeek_long() {
        return week_long;
    }

    public void setWeek_long(String week_long) {
        this.week_long = week_long;
    }

    public String getMonth_long() {
        return month_long;
    }

    public void setMonth_long(String month_long) {
        this.month_long = month_long;
    }

    public String getMonth() {
        return month;
    }

    public void setMonth(String month) {
        this.month = month;
    }

    public String getContext() {
        return context;
    }

    public void setContext(String context) {
        this.context = context;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getWeek() {
        return week;
    }

    public void setWeek(String week) {
        this.week = week;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    @Override
    public String toString() {
        return "Card{" +
                "cardId=" + cardId +
                ", createTime=" + createTime +
                ", title='" + title + '\'' +
                '}';
    }

    public long getCardId() {
        return cardId;
    }

    public void setCardId(long cardId) {
        this.cardId = cardId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}
